home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
1 PutContentsIn Igor Pro Folder
/
WaveMetrics Procedures
/
Graphing
/
Graph Utility Procs
< prev
next >
Wrap
Text File
|
1996-01-30
|
3KB
|
94 lines
// Graph Utility Procs, Version 1.2, JP960124
// Version 1.1 created to be liberal name aware. Also added option to CopyTraceSettings.
// Version 1.2, added ApplyStyleMacro.
#include <Strings as Lists>
#include <String Substitution>
#pragma rtGlobals=1 // This mainly acts as notice that this proc is Igor 3.0 savvy
// This routine reads the settings of the srcaxis of the top graph and copies them
// to the destaxis
Function CopyAxisSettings(srcaxis,destaxis)
String srcaxis,destaxis
String info= AxisInfo("",srcaxis)
Variable sstop= strsearch(info, "RECREATION:", 0)
info= info[sstop+strlen("RECREATION:"),1e6] // want just recreation stuff
Variable i=0
String dstr= "("+destaxis+")" // i.e., (left)
String sitem,xstr
do
sitem= GetStrFromList(info,i,";")
if( strlen(sitem) == 0 )
break;
endif
xstr= "ModifyGraph "+StrSubstitute("(x)",sitem,dstr)
Execute xstr
i+=1
while(1)
End
// This routine reads the settings of the given trace on the top graph and copies them
// to the destination trace
// Modifyed 951107,LH: Can now accept either a wave name and instance or a
// trace name. To use the later, specify -1 for the instance.
//
Function CopyTraceSettings(srcwave,srcinstance,destwave,destinstance)
String srcwave,destwave
Variable srcinstance,destinstance
if( srcinstance == -1 )
srcinstance= 0 // only used by TraceInfo which knows how to handle trace name
endif
String info= TraceInfo("",srcwave,srcinstance)
Variable sstop= strsearch(info, "RECREATION:", 0)
info= info[sstop+strlen("RECREATION:"),1e6] // want just recreation stuff
Variable i=0
String dstr
if( destinstance == -1 )
dstr= "("+destwave+")" // i.e., (jack#1)
else
dstr= "("+PossiblyQuoteName(destwave)+"#"+num2istr(destinstance)+")"
endif
String sitem,xstr
do
sitem= GetStrFromList(info,i,";")
if( strlen(sitem) == 0 )
break;
endif
xstr= "ModifyGraph "+StrSubstitute("(x)",sitem,dstr)
Execute xstr
i+=1
while(1)
End
// This routine applies the style macro contained in styleMacroStr to the top window
// The usual method of acquiring the style macro is
// String styleMacroStr= WinRecreation("",1) | "" means top window
Function ApplyStyleMacro(styleMacroStr)
String styleMacroStr
String startSrch= "modifying window...\r"
Variable sstart= strsearch(styleMacroStr,startSrch, 0)
Variable ssend= strsearch(styleMacroStr, "EndMacro", 0)
if( (sstart < 0) %| (ssend <= sstart) )
return 1 // failure
endif
Variable line=2 // skip line 0 and line 1
String cmd
do
cmd= GetStrFromList(styleMacroStr,line,"\r")
if( CmpStr(cmd,"EndMacro") == 0 )
break;
endif
Execute cmd
line+=1
while(1)
return 0 // success
End